#include "point.h"
#include "icell.h"
#include "complex_cubic.h"
#include "parser.h"

#include <iostream>

#define DIM_COMP 2
#define DIM_POINT 2
#define DIM_0 0
#define DIM_1 1
#define DIM_2 2

int main(int argc, char* argv[])
{
	std::cout << "====== MAIN ======" << std::endl;
	
	
	if (argc != 2) 
	{
		std::cout << "Les parametres d'entree ne sont pas correct \n" << std::endl;
		std::cout << "./iCube <LeNomDuFichierDEntree>\n" << std::endl;
	}
	else
	{
		Parser pParser;
		std::vector<std::vector<std::string>*>* sAllLines = pParser.ParseFile(argv[1]);
		if (sAllLines == NULL)
		{
			std::cout << "Impossible de parser le fichier : " << argv[1] << std::endl;
		}
		else
		{
			if (atoi(sAllLines->at(0)->at(0).c_str()) != DIM_COMP ||
				atoi(sAllLines->at(0)->at(1).c_str()) != DIM_POINT)
			{
				std::cout << "La dimension du complexe et la dimension des points ne sont pas correct" << std::endl;
			}
			else
			{
				ComplexCubic<DIM_COMP, DIM_POINT, int> cc ;
				std::cout << "Le complexe cubique a été créé" << std::endl;
				
				for (int i = 0 ; i < sAllLines->at(1)->size(); i++)
				{
					for (int j = 0; j < atoi(sAllLines->at(1)->at(i).c_str()); j++)
					{
						if (i == DIM_0)
						{
							ICell<DIM_0, DIM_POINT, int>* ic = new ICell<DIM_0, DIM_POINT, int>;
							cc.AddICell(ic);
						}
						else if (i == DIM_1)
						{
							ICell<DIM_1, DIM_POINT, int>* ic = new ICell<DIM_1, DIM_POINT, int>;
							cc.AddICell(ic);
						}
						else if (i == DIM_2)
						{
							ICell<DIM_2, DIM_POINT, int>* ic = new ICell<DIM_2, DIM_POINT, int>;
							cc.AddICell(ic);
						}
					}
				}
			}
		}
	}
	
	//ICell<2, 3, int> ic1;
	//ComplexCubic<2, 2, int> cc1;
	//std::cout << "Le complexe cubique a été créé\n" << std::endl;
	
		/*
		if ()
		
		
		
                       
            //On exploite les données collectées
			if (atoi(linesVV[0][0].c_str()) != DIM_COMP || 
				atoi(linesVV[0][1].c_str()) != DIM_POINT) 
			{
			}
			else
			{
				
				//Creation du complexe cubique
				ComplexCubic<DIM_COMP, DIM_POINT, int> cc ;
				cout<<"Le complexe cubique a été créé\n"<<endl;
				//createComplexCubic(atoi(linesVV[0][0].c_str()), atoi(linesVV[0][1].c_str()));
				
				
				vector<int> nbICell;
				for (int i = 1 ; i < linesVV.size() ; i++) // On saute la premiere ligne car c'est pour le complexe cubique deja cree
				{
					
					if (i == 1) //On definit le nombre de icell
					{
					
						cout<<"Il y aura :"<<endl;
						for (int j = 0 ; j < linesVV[i].size(); j++)
						{
							int k = atoi(linesVV[i][j].c_str());
							nbICell.push_back(k);
							cout<<k<<" "<<j<<"-cellule(s)"<<endl;
						}
					}
					else//On cré les i-cell
					{
						//les points
						for (int k = 2 ; k < nbICell[0] + 2 ; k++)
						{
							//ICell<0, 2, int> ic;
						}
					}            	
				}            
			}
		}
        
	}
	*/
	

	/*
	std::cout << "==== CREATION D'UNE ICELLULE ====" << std::endl;
	ICell<2, 3, float> ic1;
	
	std::cout << "== GetBorderCells ==" << std::endl;
	std::vector<VirtualICell*> icBorderCells = *ic1.GetBorderCells();
	for (int i = 0; i < icBorderCells.size(); i++)
	{
		std::cout << "Etape " << i << std::endl;
		icBorderCells[i]->Display();
	}
	
	std::cout << "== Display ==" << std::endl;
	ic1.Display();
	
	std::cout << std::endl << std::endl;
	std::cout << "=== CREATION D'UN COMPLEXE CUBIQUE ===" << std::endl;
	//ComplexCubic<3, 3, float> cc1;
	//std::cout << "IsValid : " << cc1.IsValid() << std::endl;
	
	//cc1.FindICell(&ic1);
	
	ICell<0, 2, int> ic2;
	//cc1.AddICell(&ic2);
	
	ic1.Remove();
	*/
	
	return 0;
}


